package zhaojin;

/**
 * Created by asus on 2017/12/2.
 */
public class Element implements Comparable<Element>{
    private int weight;
    private int value;
    private int id;

    public int getWeight() {
        return weight;
    }

    public int getValue() {
        return value;
    }

    public int getId() {
        return id;
    }

    Element(){
        this(0,0,0);
    }

    Element(int id,int weight,int value){
        this.id = id;
        this.weight = weight;
        this.value = value;
    }

    public String toString(){
        return "[id:"+id+" , weight:"+weight+" , value:"+value+"]";
    }

    @Override
    public boolean equals(Object obj) {
        if(obj==null)
            return false;
        else{
            if (obj instanceof Element){
                Element e = (Element)obj;
                if (e.getId()==this.getId())
                    return true;
            }
        }
        return false;
    }


    @Override
    public int compareTo(Element o) {
        return id > o.id ? 1 : (id < o.id ? -1 : 0);
    }
}
